package com.scau402.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.scau402.common.annotation.Log;
import com.scau402.common.core.controller.BaseController;
import com.scau402.common.core.domain.AjaxResult;
import com.scau402.common.enums.BusinessType;
import com.scau402.system.domain.WmsBasicSettlementType;
import com.scau402.system.service.IWmsBasicSettlementTypeService;
import com.scau402.common.utils.poi.ExcelUtil;
import com.scau402.common.core.page.TableDataInfo;

/**
 * 结算方式Controller
 * 
 * @author ruoyi
 * @date 2023-06-26
 */
@RestController
@RequestMapping("/system/settlementType")
public class WmsBasicSettlementTypeController extends BaseController
{
    @Autowired
    private IWmsBasicSettlementTypeService wmsBasicSettlementTypeService;

    /**
     * 查询结算方式列表
     */
    @PreAuthorize("@ss.hasPermi('system:settlementType:list')")
    @GetMapping("/list")
    public TableDataInfo list(WmsBasicSettlementType wmsBasicSettlementType)
    {
        startPage();
        List<WmsBasicSettlementType> list = wmsBasicSettlementTypeService.selectWmsBasicSettlementTypeList(wmsBasicSettlementType);
        return getDataTable(list);
    }

    /**
     * 导出结算方式列表
     */
    @PreAuthorize("@ss.hasPermi('system:settlementType:export')")
    @Log(title = "结算方式", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WmsBasicSettlementType wmsBasicSettlementType)
    {
        List<WmsBasicSettlementType> list = wmsBasicSettlementTypeService.selectWmsBasicSettlementTypeList(wmsBasicSettlementType);
        ExcelUtil<WmsBasicSettlementType> util = new ExcelUtil<WmsBasicSettlementType>(WmsBasicSettlementType.class);
        util.exportExcel(response, list, "结算方式数据");
    }

    /**
     * 获取结算方式详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:settlementType:query')")
    @GetMapping(value = "/{settlementType}")
    public AjaxResult getInfo(@PathVariable("settlementType") String settlementType)
    {
        return success(wmsBasicSettlementTypeService.selectWmsBasicSettlementTypeBySettlementType(settlementType));
    }

    /**
     * 新增结算方式
     */
    @PreAuthorize("@ss.hasPermi('system:settlementType:add')")
    @Log(title = "结算方式", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WmsBasicSettlementType wmsBasicSettlementType)
    {
        return toAjax(wmsBasicSettlementTypeService.insertWmsBasicSettlementType(wmsBasicSettlementType));
    }

    /**
     * 修改结算方式
     */
    @PreAuthorize("@ss.hasPermi('system:settlementType:edit')")
    @Log(title = "结算方式", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WmsBasicSettlementType wmsBasicSettlementType)
    {
        return toAjax(wmsBasicSettlementTypeService.updateWmsBasicSettlementType(wmsBasicSettlementType));
    }

    /**
     * 删除结算方式
     */
    @PreAuthorize("@ss.hasPermi('system:settlementType:remove')")
    @Log(title = "结算方式", businessType = BusinessType.DELETE)
	@DeleteMapping("/{settlementTypes}")
    public AjaxResult remove(@PathVariable String[] settlementTypes)
    {
        return toAjax(wmsBasicSettlementTypeService.deleteWmsBasicSettlementTypeBySettlementTypes(settlementTypes));
    }
}
